package com.mashiguang.remotelogin;

import org.jasig.cas.authentication.principal.AbstractPersonDirectoryCredentialsToPrincipalResolver;
import org.jasig.cas.authentication.principal.Credentials;

public class UsernamePasswordCredentialsToPrincipalResolver extends
		AbstractPersonDirectoryCredentialsToPrincipalResolver {

	public boolean supports(Credentials credentials) {
		return credentials != null
			&& UsernamePasswordAuthenticationHandler.class.isAssignableFrom(credentials.getClass());
	}

	@Override
	protected String extractPrincipalId(Credentials credentials) {
		
		UsernamePasswordCredentials handler = (UsernamePasswordCredentials) credentials;
		
		return handler.getUsername();
	}

}
